package com.xique.door.service.impl;


import com.xique.common.core.text.Convert;
import com.xique.common.core.utils.DateUtils;
import com.xique.door.bean.domain.BuildFloor;
import com.xique.door.mapper.BuildFloorMapper;
import com.xique.door.service.IBuildFloorService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 楼层Service业务层处理
 * 
 * @author caogq
 * @date 2021-09-09
 */
@Service
public class BuildFloorServiceImpl implements IBuildFloorService
{
    @Autowired
    private BuildFloorMapper buildFloorMapper;

    /**
     * 查询楼层
     * 
     * @param id 楼层ID
     * @return 楼层
     */
    @Override
    public BuildFloor selectBuildFloorById(Long id)
    {
        return buildFloorMapper.selectBuildFloorById(id);
    }

    /**
     * 查询楼层列表
     * 
     * @param buildFloor 楼层
     * @return 楼层
     */
    @Override
    public List<BuildFloor> selectBuildFloorList(BuildFloor buildFloor)
    {
        return buildFloorMapper.selectBuildFloorList(buildFloor);
    }

    /**
     * 新增楼层
     * 
     * @param buildFloor 楼层
     * @return 结果
     */
    @Override
    public int insertBuildFloor(BuildFloor buildFloor)
    {
        buildFloor.setCreateTime(DateUtils.getNowDate());
        return buildFloorMapper.insertBuildFloor(buildFloor);
    }

    @Override
    public int insertBuildFloors(List<BuildFloor> buildFloors) {
        if (CollectionUtils.isEmpty(buildFloors)) {
            return 1;
        }
        buildFloors.forEach(item -> {
            item.setCreateTime(DateUtils.getNowDate());
        });
        return buildFloorMapper.insertBuildFloors(buildFloors);
    }

    /**
     * 修改楼层
     * 
     * @param buildFloor 楼层
     * @return 结果
     */
    @Override
    public int updateBuildFloor(BuildFloor buildFloor)
    {
        buildFloor.setUpdateTime(DateUtils.getNowDate());
        return buildFloorMapper.updateBuildFloor(buildFloor);
    }

    /**
     * 删除楼层对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteBuildFloorByIds(String ids)
    {
        return buildFloorMapper.deleteBuildFloorByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除楼层信息
     * 
     * @param id 楼层ID
     * @return 结果
     */
    public int deleteBuildFloorById(Long id)
    {
        return buildFloorMapper.deleteBuildFloorById(id);
    }
}
